The String\f1 class provides dynamic, efficient strings for a
C++ application. The
intent is to provide efficient \f3char*\f1-like functionality that frees the
programmer from worrying about memory allocation and deallocation problems, yet
retains the speed and compactness of a standard \f3char*\f1 implementation. The
\f3String\f1 class is dynamic in the sense that if an operation such as concatenate results in more characters than can fit in the currently allocated memory, the string object \f2grows\f1 according to some established size or ratio value. All typical string operations are provided, including concatenation, case-sensitive and case-insensitive lexical comparison, string search, yank, delete, and
replacement. System-provided functions for \f3char*\f1 such as \f3strcpy\f1 and \f3strcmp\f1 are also available via the overloaded \f3operator char* \f1 member function.
.SH Base Classes
.SH Friend Classes
None
.SH Constructors
.TP
String ();
Initializes an empty string object with a default size block of memory
allocated to hold 100 characters.
.TP
\f3String (char \f2c\f3);\f1
Initializes a string object with the default size block of memory allocated to
hold 100 characters whose value is the string consisting of the single
character argument \f2c\f1.
.TP
\f3String (const char* \f2str\f3);\f1
Initializes a string object with the default size block of memory allocated to
hold 100 characters whose value is copied from the specified character string
argument
str .
If \f2str\f1 is longer, the string will grow as necessary.
.TP
\f3String (const char* \f2str\f3, long \f2size\f3);\f1
Allocates an initial block of memory the size of the integer argument \f2size\f1, or
the s\f3trlen(\f2str\f3)\f1, whichever is longer. and initializes the string object with a copy of the specified character string \f2str\f1. Note that \f2size\f1 is ignored if less than the length of \f2str\f1.
.TP
\f3String (const String& \f2str\f3);\f1
Duplicates the size and value of another string object \f2str\f1.
.TP
\f3String (const String& \f2str\f3, long \f2size)\f3;\f1
Duplicates the size and value of another string object \f2str\f1 by allocating an
initial block of memory to be the size of the integer argument \f2size\f1, or
\f3strlen(\f2str\f3)\f1, whichever is longer. The duplication is then performed.
.SH Member Functions
.TP
inline long capacity () const;
Returns the maximum number of characters that the string object can contain
without having to grow.
.TP
void clear ();
Resets the
NULL
character string terminator to the beginning of the string and
sets the length of the string to zero.
.TP
\f3Boolean insert (const char* \f2str\f3, long \f2position\f3);\f1
Inserts a copy of the sequence of characters pointed to by the first argument
\f2str\f1 at the zero-relative index provided by the second argument \f2position\f1. This function returns
TRUE
if successful; otherwise, this function returns
FALSE
if the index is out of range.
.TP
inline operator char* () const;
Provides an implicit conversion operator to convert a string object into a
\f3char*\f1 value.
.TP
\f3String operator+ (char \f2c\f3);\f1
Overloads the addition operator to concatenate a single character \f2c\f1 to a string object. This function returns a new string object, via the stack.
.TP
\f3String operator+ (const char* \f2str\f3);\f1
Overloads the addition operator to concatenate a copy of the specified
character sequence \f2str\f1 to a string object. This function returns a new string object.
.TP
\f3String operator+ (const String& \f2str\f3);\f1
Overloads the addition operator to concatenate the value of the specified
string object \f2str\f1 to a string object. This function returns a new string
object.
.TP
\f3inline String& operator= (char \f2c\f3);\f1
Overloads the assignment operator to assign a single character \f2c\f1 to a string object. This function returns a reference to the modified string object.